package com.kata.chapter12;

/**
 * Created by Solidsnake on 2014/12/4.
 */
public class ExceptionRollBackTransaction extends Transaction {

    public ExceptionRollBackTransaction(IConnection connection) {
        super(connection);
    }

    @Override
    protected void before() {
        System.out.println("事务开始, 不作任何事");
    }

    @Override
    public void runingTransaction() {
        this.before();
        try {
            super.connection.commit("error");
        }catch(Exception e) {
            super.connection.rollBack();
        }
        this.after();
    }

    @Override
    protected void after() {
        System.out.println("事务开始, 不作任何事");
    }
}
